#include <iostream>
#include <string>

int main() {
    std::string s1;
    
    std::string s;
    std::cin >> s;
    
    for (char c : s) {
        if ( c=='(' ) {
            s1 += c;
        }
        if ( c==')' ) {
            if (s1.length() > 0){
                if (s1[ s1.lenght() - 1 ] == '(' ) {
                    s1.pop_back
                }
            }
        }
}   }
